/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * conversorArmazenamento.java
 *
 * Created on 27/10/2011, 13:54:01
 */

package br.com.fatecpg.tp1.formularios;

import javax.swing.JOptionPane;

/**
 *
 * @author Bia
 */
public class conversorArmazenamento extends javax.swing.JInternalFrame {

    /** Creates new form conversorArmazenamento */
    public conversorArmazenamento() {
        initComponents();
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        BitRadioButton = new javax.swing.JRadioButton();
        KiloBitRadioButton = new javax.swing.JRadioButton();
        MegaBitRadioButton1 = new javax.swing.JRadioButton();
        GigaBitRadioButton = new javax.swing.JRadioButton();
        bit = new javax.swing.JLabel();
        kiloBitLabel = new javax.swing.JLabel();
        megaBitLabel = new javax.swing.JLabel();
        gigaBitLabel = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();

        setBackground(new java.awt.Color(63, 98, 104));
        setClosable(true);
        setIconifiable(true);
        setTitle("Armazenamento de Dados");

        jPanel1.setBackground(new java.awt.Color(122, 167, 175));

        jLabel1.setText("Valor:");

        BitRadioButton.setBackground(new java.awt.Color(122, 167, 175));
        buttonGroup1.add(BitRadioButton);
        BitRadioButton.setText("Bit");
        BitRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BitRadioButtonActionPerformed(evt);
            }
        });

        KiloBitRadioButton.setBackground(new java.awt.Color(122, 167, 175));
        buttonGroup1.add(KiloBitRadioButton);
        KiloBitRadioButton.setText("KiloBit");
        KiloBitRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                KiloBitRadioButtonActionPerformed(evt);
            }
        });

        MegaBitRadioButton1.setBackground(new java.awt.Color(122, 167, 175));
        buttonGroup1.add(MegaBitRadioButton1);
        MegaBitRadioButton1.setText("MegaBit");
        MegaBitRadioButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MegaBitRadioButton1ActionPerformed(evt);
            }
        });

        GigaBitRadioButton.setBackground(new java.awt.Color(122, 167, 175));
        buttonGroup1.add(GigaBitRadioButton);
        GigaBitRadioButton.setText("GigaBit");
        GigaBitRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GigaBitRadioButtonActionPerformed(evt);
            }
        });

        bit.setText("Bit:");

        kiloBitLabel.setText("KiloBit:");

        megaBitLabel.setText("MegaBit:");

        gigaBitLabel.setText("Gigabit:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(BitRadioButton)
                        .addGap(18, 18, 18)
                        .addComponent(KiloBitRadioButton)
                        .addGap(18, 18, 18)
                        .addComponent(MegaBitRadioButton1)
                        .addGap(18, 18, 18)
                        .addComponent(GigaBitRadioButton))
                    .addComponent(bit)
                    .addComponent(kiloBitLabel)
                    .addComponent(megaBitLabel)
                    .addComponent(gigaBitLabel))
                .addContainerGap(36, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BitRadioButton)
                    .addComponent(KiloBitRadioButton)
                    .addComponent(MegaBitRadioButton1)
                    .addComponent(GigaBitRadioButton))
                .addGap(18, 18, 18)
                .addComponent(bit)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(kiloBitLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(megaBitLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(gigaBitLabel)
                .addContainerGap(72, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BitRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BitRadioButtonActionPerformed

        double bitBit = ((Double.parseDouble(jTextField1.getText())));
        bit.setText(bitBit + " Bit");

        double bitKilo = ((Double.parseDouble(jTextField1.getText()))
                / 1024);
        kiloBitLabel.setText(bitKilo+ " KiloBit");

        double bitMega = ((Double.parseDouble(jTextField1.getText()))
                / 1048576);
        megaBitLabel.setText(bitMega  + " MegaBit");

        double bitGiga = ((Double.parseDouble(jTextField1.getText()))
                / 1073741824);
                //+( 9 * Math.pow(10, -4)));
        gigaBitLabel.setText(bitGiga + " GigaBit");

    }//GEN-LAST:event_BitRadioButtonActionPerformed

    private void KiloBitRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_KiloBitRadioButtonActionPerformed
        double kiloBit = ((Double.parseDouble(jTextField1.getText()))
                * 1024);
        bit.setText(kiloBit + " Bit");

        double kiloKilo = ((Double.parseDouble(jTextField1.getText()))
                );
        kiloBitLabel.setText(kiloKilo+ " KiloBit");

        double kiloMega = ((Double.parseDouble(jTextField1.getText()))
                / 1024);
        megaBitLabel.setText(kiloMega  + " MegaBit");

        double bitGiga = ((Double.parseDouble(jTextField1.getText()))
                / 1048576);
                //+( 9 * Math.pow(10, -4)));
        gigaBitLabel.setText(bitGiga + " GigaBit");
    }//GEN-LAST:event_KiloBitRadioButtonActionPerformed

    private void MegaBitRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MegaBitRadioButton1ActionPerformed
double megaBit = ((Double.parseDouble(jTextField1.getText()))
                * 1048576);
        bit.setText(megaBit + " Bit");

        double megaKilo = ((Double.parseDouble(jTextField1.getText()))
               * 1024 );
        kiloBitLabel.setText(megaKilo+ " KiloBit");

        double megaMega = ((Double.parseDouble(jTextField1.getText()))
               );
        megaBitLabel.setText(megaMega  + " MegaBit");

        double megaGiga = ((Double.parseDouble(jTextField1.getText()))
                / 1024);
        gigaBitLabel.setText(megaGiga + " GigaBit");
    }//GEN-LAST:event_MegaBitRadioButton1ActionPerformed

    private void GigaBitRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GigaBitRadioButtonActionPerformed
        double megaBit = ((Double.parseDouble(jTextField1.getText()))
                * 1073741824);
        bit.setText(megaBit + " Bit");

        double megaKilo = ((Double.parseDouble(jTextField1.getText()))
               * 1048576 );
        kiloBitLabel.setText(megaKilo+ " KiloBit");

        double megaMega = ((Double.parseDouble(jTextField1.getText()))
               * 1024);
        megaBitLabel.setText(megaMega  + " MegaBit");

        double megaGiga = ((Double.parseDouble(jTextField1.getText()))
                );
        gigaBitLabel.setText(megaGiga + " GigaBit");
    }//GEN-LAST:event_GigaBitRadioButtonActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton BitRadioButton;
    private javax.swing.JRadioButton GigaBitRadioButton;
    private javax.swing.JRadioButton KiloBitRadioButton;
    private javax.swing.JRadioButton MegaBitRadioButton1;
    private javax.swing.JLabel bit;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel gigaBitLabel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JLabel kiloBitLabel;
    private javax.swing.JLabel megaBitLabel;
    // End of variables declaration//GEN-END:variables

}
